package com.aplink.generic.pojo.googlemaps;

import java.lang.reflect.Type;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;

public class Duration implements JsonDeserializer<Duration> {
	private String mText;
	private int mValue;

	@Override
	public Duration deserialize(JsonElement element, Type type,
	        JsonDeserializationContext context) throws JsonParseException {
		JsonObject jsonObject = element.getAsJsonObject();
		mText = jsonObject.get("text").getAsString();
		mValue = jsonObject.get("value").getAsInt();
		return this;
	}

	/**
	 * contains a string representation of the duration.
	 *
	 * @return
	 */
	public String getText() {
		return mText;
	}

	/**
	 * value indicates the duration in seconds.
	 *
	 * @return
	 */
	public int getValue() {
		return mValue;
	}

	public void setText(String text) {
		mText = text;
	}

	public void setValue(int value) {
		mValue = value;
	}
}
